package com.chhuang.ewcrm.utils;

import javafx.scene.control.TextFormatter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author chhuang
 * @create 2020-10-30-10:47
 */
public class UpCastTextFilter extends LengthTextFilter {

    public UpCastTextFilter(){};
    public UpCastTextFilter(int maxLength){
        this.maxLength = maxLength;
    }

    @Override
    public TextFormatter.Change apply(TextFormatter.Change change) {
        change = super.apply(change);
        if(change!=null){
            String text = change.getText();
            if(StringUtils.isNotEmpty(text)){
                change.setText(text.toUpperCase());
            }
        }
        return change;
    }
}
